package jmine.tec.web.front.pack;

import jmine.tec.database.pack.populator.AbstractPopulatorDataSource;
import jmine.tec.database.pack.populator.PopulatorBean;
import jmine.tec.utils.collection.Mapper;
import jmine.tec.utils.collection.MapperUtils;
import jmine.tec.web.front.domain.BackOfficeRequestStatus;
import bancosys.tec.persist.dao.BaseDAO;

/**
 * Data source para exportação.
 * 
 * @author wagner.tsuchiya
 */
public class BackOfficeRequestStatusDataSource extends AbstractPopulatorDataSource<BackOfficeRequestStatus> {
    private BaseDAO<BackOfficeRequestStatus> backOfficeRequestStatusDAO;

    /**
     * {@inheritDoc}
     */
    public Iterable<PopulatorBean<BackOfficeRequestStatus>> load() {
        return MapperUtils.mapList(this.backOfficeRequestStatusDAO.findAllOrderedByPk(),
                new Mapper<BackOfficeRequestStatus, PopulatorBean<BackOfficeRequestStatus>>() {
                    public PopulatorBean<BackOfficeRequestStatus> apply(BackOfficeRequestStatus input) {
                        return new PopulatorBean<BackOfficeRequestStatus>(input, "front", "status", input.getName().toLowerCase() + ".xml");
                    }
                });
    }

    /**
     * @param backOfficeRequestStatusDAO the backOfficeRequestStatusDAO to set
     */
    public void setBackOfficeRequestStatusDAO(BaseDAO<BackOfficeRequestStatus> backOfficeRequestStatusDAO) {
        this.backOfficeRequestStatusDAO = backOfficeRequestStatusDAO;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return "PropertiesPopulatorDataSource";
    }

}
